package com.voice.server.repository;

import com.voice.server.entity.UserRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/*
 * @auther: wangjiacai
 *
 * @create: 2018-04-23 11:54:50
 */
public interface UserRoleRepository extends JpaRepository<UserRole,String> {

    List<UserRole> findByUserId(String userId);

    @Query("select roleId from UserRole where userId=?1")
    List<String> findRoleIdByUserId(String userId);

    @Query("select userId from UserRole where roleId =?1")
    List<String> findUserIdByRoleId(String roleId);

    void deleteByRoleId(String roleId);
}
